package com.maze;
public class Position {
	
	/**
     * Creates a new <code>Position</code> instance.
     *
     * @param x_coord Position's x coordinate (<code>int</code>)
     * @param y_coord Position's y coordinate (<code>int</code>)
     */
	 private int x_coord;
	 private int y_coord;
	 enum DIR {DIR_UP, DIR_DOWN, DIR_LEFT, DIR_RIGHT}
	 public Position(int x, int y) {
		x_coord = x;
		y_coord = y ;
	}
	 public int getX() {
		 return x_coord;
	 }
	 
	 public int getY() {
		 return y_coord;
	 }
	
	
	/**
     * <code>hashCode</code> method for Position.
     *
     * @return the hash code for the object based on x_coord, y_coord
     */
	public int hashCode() {
		return 13*x_coord + 17*y_coord;
	}
	
	/**
     * <code>equals</code> method for Position.
     *
     * @param obj Object to compare with
     * @return true if objects are equal ( x_coord and y_coord of two objects are equal)
     */
    public boolean equals(Object obj) {
    	if (obj == null || !(obj instanceof Position)) // if obj is null, the part after || will not be evaluated
    		return false;
    	Position p = (Position) obj;
    	return (x_coord == p.x_coord) && (y_coord == p.y_coord);
    }
    
    /**
     * <code>move</code> method for Position.
     *
     * @param dir DIR to change the coordinate
     */
    public void move(DIR dir) {
    	switch(dir) {
    	case DIR_UP :
    		y_coord = y_coord-1;
    		break;
    	case DIR_DOWN :
    		y_coord = y_coord+1;
    		break;
    	case DIR_LEFT :
    		x_coord = x_coord-1;
    		break;
    	case DIR_RIGHT :
    		x_coord = x_coord+1;
    		break;
		default:
			break;
    		
    	}
    	   
    }

	
	
}
